package 线程.day3.加法器;

import java.util.concurrent.CyclicBarrier;

public class Test
{
    public static void main(String[] args) {
        CyclicBarrier cb=new CyclicBarrier(6, new Runnable() {
            @Override
            public void run() {
                System.out.println("-------------项楚灭秦-----------");
            }
        });

        String[]arr={"韩","赵","魏","楚","燕","齐"};
        for(String msg:arr){
            new Thread(new Runnable() {
                public void run() {
                    System.out.println(Thread.currentThread().getName()+"被秦灭。。。");
                    try {
                        cb.await();//加1,并阻塞
                    } catch (Exception e) {}
                    System.out.println(Thread.currentThread().getName()+"参与楚汉战争。。。");
                }
            },msg).start();
        }
    }
}
